<template>
    <div style="height:100%;width:100%;position:relative;">
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="poptitle" :visible.sync="dialogTableVisible" @close="popcommonclose" v-if="dialogTableVisible" ref="popcommondialog">
            <rm-pop-common @cancel="dialogTableVisible=false,popcommonclose()" :datatype="'smp_LocationCode'" :rptunitid="LibridPop" @change="popchange" ref="popcommonLeft"></rm-pop-common>
        </el-dialog>
       
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="" :visible.sync="dialogDestroyVisible" width="25%"  >
            <table style="height:10%">
                <tr></tr>
            </table>
            <div class="loading"><div><span></span></div><div><span></span></div><div><span></span></div></div>
            <table style="height:15%">
                <tr></tr>
            </table>
            <table>
                <tr></tr>
            </table>
            <table>
                <tr></tr>
            </table>
            <div  style="text-align:center;font-family:'microsoft yahei';color:black">
                {{destroying}}
            </div>
        </el-dialog>
        

        <div class="pagetop" :style="{ height: OtherShow?'120px':'45px' }"> 
            <template>
                <div style="width:100%;float:left">
                    <div style="float:left;width:100%">
                        <table style="font-size:12px;float:left;position:absolute;top:3px" class="table1style">
                            <tr >
                                <td width="270px" class="top-condition" align="left">
                                    <span style="margin-right:5px;">留样条码</span>
                                    <div class="el-input el-input--small">
                                        <el-input v-model.trim="txtSmp_Barcode"  @keyup.enter.native="inputsmpbarcode(txtSmp_Barcode)" placeholder="" style="width:250px" ref="rSmp_Barcode"></el-input>
                                    </div>
                                </td>
                                <td align="right" >
                                    <el-button style="float:right;margin-left:10px" icon="el-icon-upload2" v-has="'PEXPORT'" @click="BtnExport()">导出</el-button>
                                    <!-- <el-button  style="float:right" icon="el-icon-refresh-right" @click="BtnPrint()">打印</el-button> -->
                                    <el-button  style="float:right" icon="el-icon-sort" @click.native="BtnDestroy()">销毁</el-button>
                                    <el-button  style="float:right" icon="el-icon-close" @click.native="BtnClear()">清除</el-button>
                                    <!-- <el-button style="float:right" icon="el-icon-upload"  @click="BtnQuery()">打印样式</el-button> -->
                                    <!-- <el-button  style="float:right" icon="el-icon-delete" v-has="'PDELETE'" @click="BtnDelete()" :disabled="changeflag">删除</el-button> -->
                                    <!-- <el-button  style="float:right" icon="el-icon-search" type="primary" v-has="'PINQUERY'" @click="BtnQuery()">查询</el-button> -->
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </template>
        </div> 

        <div class="pagecenter" :style="{ top: OtherShow?'115px':'55px'}">
            <div :class="'pagemain'">
                <vxe-table :style="{ height: OtherShow?'100%'-50+ 'px':'100%'}" row-id='smp_sampleid' 
                 :select-config="{checkRowKeys:rowSmpIDArr,showHeader:true,reserve:true,trigger:'cell'}" 
                :sort-config="{trigger: 'cell'}"  :data.sync="leftTableData" border fit  height="auto" header-align="center" @select-change="selectChange"
                highlight-current-row highlight-hover-row @select-all="selectChangeAll"
                    ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe :cell-class-name="CellClassName"  >
                    <vxe-table-column type="selection" header-align="center" align="center"  width="40px" ></vxe-table-column>
                    <vxe-table-column field="smp_registerdate" title="登记日期" width="120px"></vxe-table-column>
                    <vxe-table-column field="smp_registerno" title="标本号" width="120px"></vxe-table-column>
                    <vxe-table-column field="smp_type" title="标本类型" width="100px"></vxe-table-column>
                    <vxe-table-column field="pat_no" title="病人号" width="120px"></vxe-table-column>
                    <vxe-table-column field="pat_cardno" title="就诊卡号" width="150px"></vxe-table-column>
                    <vxe-table-column field="pat_name" title="病人姓名" width="120px"></vxe-table-column>
                    <vxe-table-column field="pat_sex" title="性别" width="120px"></vxe-table-column>
                    <vxe-table-column field="smp_barcode" title="条码号" width="100px"></vxe-table-column>
                    <vxe-table-column field="locationname" title="样本位置" width="150px"></vxe-table-column>
                    <vxe-table-column field="smp_status" title="状态" width="80px" :formatter="['formatSelect', $opt.smpSampleOption]" ></vxe-table-column>
                    <vxe-table-column field="posinrow" title="行号" width="60px"></vxe-table-column>
                    <vxe-table-column field="posincol" title="列号" width="60px"></vxe-table-column>
                    <vxe-table-column field="locationcode" title="位置编码" width="100px"></vxe-table-column>
                    <vxe-table-column field="smp_quantity" title="标本量" width="100px"></vxe-table-column>
                    <vxe-table-column field="smp_unit" title="单位" width="100px"></vxe-table-column>
                    <vxe-table-column field="smp_comments" title="标本备注" width="200px"></vxe-table-column>
                    <vxe-table-column field="indate" title="最后入库日期" width="120px"></vxe-table-column>
                    <vxe-table-column field="inuser" title="入库人" width="100px"></vxe-table-column>
                    <vxe-table-column field="lenddate" title="最后借出日期" width="120px"></vxe-table-column>
                    <vxe-table-column field="lenduser" title="借出人" width="100px"></vxe-table-column>
                    <vxe-table-column field="finishdate" title="完成日期" width="120px"></vxe-table-column>
                    <vxe-table-column field="finishusername" title="完成人" width="100px"></vxe-table-column>
                    <vxe-table-column field="outdate" title="抛弃日期" width="120px"></vxe-table-column>
                    <vxe-table-column field="outuser" title="抛弃人" width="100px"></vxe-table-column>
                    <vxe-table-column field="lendtime" title="借出次数" width="120px"></vxe-table-column>
                    <vxe-table-column field="pat_birth" title="病人生日" width="120px"></vxe-table-column>
                    <vxe-table-column field="pat_agestr" title="病人年龄" width="80px"></vxe-table-column>
                    <vxe-table-column field="pat_typecode" title="病人类型" width="80px"></vxe-table-column>
                    <vxe-table-column field="pat_diag" title="临床诊断" width="180px"></vxe-table-column>
                    <vxe-table-column field="pat_address" title="联系地址" width="250px"></vxe-table-column>
                    <vxe-table-column field="pat_nation" title="国家/民族" width="120px"></vxe-table-column>
                    <vxe-table-column field="pat_idcardno" title="身份证号" width="220px"></vxe-table-column>
                    <vxe-table-column field="pat_phone" title="联系电话" width="150px"></vxe-table-column>
                    <vxe-table-column field="pat_height" title="身高" width="100px"></vxe-table-column>
                    <vxe-table-column field="weight" title="体重" width="100px"></vxe-table-column>
                    <vxe-table-column field="abo_bldtype" title="ABO血型" width="80px"></vxe-table-column>
                    <vxe-table-column field="rh_bldtype" title="RH血型" width="80px"></vxe-table-column>
                    <vxe-table-column field="req_deptno" title="申请科室" width="150px"></vxe-table-column>
                    <vxe-table-column field="pat_class" title="病人分类" width="80px"></vxe-table-column>
                    <vxe-table-column field="pat_sourcetype" title="病人来源" width="80px"></vxe-table-column>
                    <vxe-table-column field="hospitalname" title="外院名称" width="120px"></vxe-table-column>
                    <vxe-table-column field="sourcecode" title="来源编号" width="80px"></vxe-table-column>
                    <vxe-table-column field="pathology" title="病理诊断" width="80px"></vxe-table-column>
                    <vxe-table-column field="familyornot" title="家族史" width="60px"></vxe-table-column>
                    <vxe-table-column field="tumorsize" title="肿瘤大小" width="60px"></vxe-table-column>
                    <vxe-table-column field="tumornumber" title="肿瘤个数" width="60px"></vxe-table-column>
                    <vxe-table-column field="lymphanumber" title="淋巴结数" width="60px"></vxe-table-column>
                    <vxe-table-column field="istransfer" title="远处转移" width="60px"></vxe-table-column>
                    <vxe-table-column field="tnm" title="TNM" width="60px"></vxe-table-column>
                    <vxe-table-column field="isoperation" title="是否手术" width="60px"></vxe-table-column>
                    <vxe-table-column field="postoperativedays" title="术后天数" width="60px"></vxe-table-column>
                    <vxe-table-column field="operationdate" title="术后日期" width="60px"></vxe-table-column>
                    <vxe-table-column field="remarks" title="备注" width="120px"></vxe-table-column>
                    <vxe-table-column field="smp_registeruser" title="登记人" width="120px"></vxe-table-column>
                    <vxe-table-column field="originbarcode" title="实验室条码" width="120px"></vxe-table-column>
                </vxe-table>
             </div>
        </div>
    </div>
</template>

<script type="text/javascript">
import { Promise } from "q"
import { invalid } from "moment"
import XE from "xe-utils" //引入工具类
XE.mixin({
    // 自定义全局的格式化处理函数
    formatSelect(cellValue, list) {
        let item = list.find((item) => item.value == cellValue);
        return item ? item.label : "";
    },
});
import rmLayoutTop from '../../../rmcompents/rm-layout-top.vue'
export default {
  components: { rmLayoutTop },
    name: "SMP227",
    data() {
        return {
            //top
            txtPatNo: "", //病人号
            txtPatCardNo: "", //就诊卡号
            txtPatName: "", //病人姓名
            txtPatAgeStr: "", //年龄
            txtShelfType1: "", //样本架号1*
            txtShelfType2: "", //样本架号2*
            txtSendHospCode: "", //送检医院*
            txtPatDiag: "", //临床诊断
            txtLendUser: "", //借出人
            txtOutUser: "", //销毁人
            txtInUser: "", //入库人
            txtLendTime: "", //借出次数 默认是0，每次借出后自动加1
            txtSmpComments: "", //标本备注
            txtSmp_Barcode: "", //条码号
            ddlLocation1: "", //冰箱位置1*
            ddlLocation2: "", //冰箱位置2*
            ddlPatSex: "", //性别 1男，2女，3未知
            ddlReqDeptNo: "", //申请科室
            ddlSmpStatus: "30", //在库状态 10登记，20打印，30入库，31移库，35归还，40借出，50遗弃，归还（借出后的入库都视为归还），抛弃，99 修改登记信息
            ddlPatTypeCode: "", //病人类型
            ddlSmpType: "", //标本类型
            chkIsReserve: false, //修改查询条件时不清空列表
            //ddltxtSmpDate1: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //留样日期-起始
            ddltxtSmpDate1:  XE.toDateString(new Date(), "yyyy-MM-dd"), //留样日期-起始
            //ddltxtSmpDate2: XE.toDateString(new Date(), "yyyy-MM-dd"), //留样日期-结束
            ddltxtSmpDate2: "",
            // ddlLendDate1: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //借出日期-起始
            // ddlLendDate2: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //借出日期-结束
            // ddltxtOutDate1: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //销毁日期-起始
            // ddltxtOutDate2: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //销毁日期-结束
            ddltxtOutDate1: "", //销毁日期-起始
            ddltxtOutDate2: "", //销毁日期-结束
            // ddltxtInDate1: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //入库日期-起始
            // ddltxtInDate2: XE.toDateString("0000-00-00", "yyyy-MM-dd"), //入库日期-结束
            loading: false,
            changeflag: false, //Btn是否启用标志
            okFirstLoading: true,
            bbjlx_Data: [],
            tableData: [],
            tempindex: 0,
            leftTableData: [],
            msgList: [],
            OtherShow: false, //展开
            //selCodeno: "", //样本库类型代码
            librid: "", //样本库ID
            LibridPop:"",
            isterm:'false',
            selSmpLibrary_Options: [], //样本库类型
            dialogTableVisible: false, //是否显示
            poptitle: "", //左侧列表通用弹出框标题
            popdatatype:"",//弹框类型
            InputCodeArr: [], //ddl数据列表
            LocationCode:{locationLeft:'',locationLeftName:'', 
                         locationRight:'',locationRightName:''}, //冰箱位置 库位CODE
            customColumns: [
                {
                  field: 'smp_sampleid',
                  visible: false
                },
              ],
            DestroyData: [], //行颜色ID
            destroying:'销毁中请稍后！', //销毁弹框提示
            dialogDestroyVisible:false,   //销毁弹窗是否显示
            tablePage: {               //分页
                total: 0,
                currentPage: 1,
                pageSize: 50
            },
            bindLeftTableData:[],        //分页查询缓存
            rowSmpIDArr:[],              //全选绑定ID
            rowSelect:[],
            allDestroy:false,            //是否全部销毁
            destroyPager:false,          //销毁分页
        }
    },
    created() {
        this.showLoad = false;
        this.ddlSmp_Library()//初始化样本库ID下拉框
         
    },
    mounted() {
        this.$refs.rSmp_Barcode.focus()
    },
    updated() {
       
    },
    methods: {

        inputsmpbarcode(){
            if(!this.txtSmp_Barcode){
                return false;
            }
            this.$tool.request({
                url: "SMP/SMP2/SMP226",
                method: "post",
                data:{
                    action: "smp_query_sampleinfo",
                    smp_barcode:this.txtSmp_Barcode,
                }
            }).then((res)=>{
                if(res.Data.length>0){
                    // if(this.leftTableData.length==0){
                    //     this.leftTableData=res.Data;
                    // }else{
                        
                    // }
                    this.leftTableData = this.leftTableData.concat(res.Data)
                    this.$refs.xTable.setCurrentRow(res.Data[0])
                }
            }).catch((e)=>{
                console.log("error",e);
            })

        },
        async BtnQuery() {
            try {
                this.destroyPager = false;

                this.allDestroy = false;    //是否销毁
                this.rowSmpIDArr = [];      //勾选ID数组(销毁行有勾选无ID不勾选)
                this.rowSelect = [];        //勾选行数据(销毁行数据)
                this.$refs.xTable.setAllSelection(false);//勾选UI

                if (this.librid>0) {
                    const res = await this.$tool.request({
                    url: "SMP/SMP2/SMP226",
                    method: "post",
                    data: {
                        action: "smp_query_samplelist",
                        librid:this.librid,
                        smp_barcode:this.txtSmp_Barcode,
                        reg_startdt:this.ddltxtSmpDate1,    //留样时间
                        reg_enddt:this.ddltxtSmpDate2,
                        preoutdatestart:this.ddltxtOutDate1,//销毁时间
                        preoutdateend:this.ddltxtOutDate2,
                        loca_startcode:this.LocationCode.locationLeft,   //冰箱位置
                        loca_endcode:this.LocationCode.locationRight,
                        shelf_startno:this.txtShelfType1,   //架子编号
                        shelf_endno:this.txtShelfType1,
                        status:this.ddlSmpStatus,           //库状态
                        inuser:this.txtInUser,                 //入库人
                        isterm:this.isterm,                 //过期标本 默认'FALSE'
                        pagesize: this.tablePage.pageSize,
                        currentpage: this.tablePage.currentPage
                    },
                })
                this.tablePage.total = res.total;
                this.bindLeftTableData = res.Data;
                //this.leftTableData =  res.Data;
                let tempdata = this.bindLeftTableData;
                this.rowSelect = [];
                this.leftTableData = [];
                for (let index = 0; index < tempdata.length; index++) {
                    if (index>=this.tablePage.pageSize * (this.tablePage.currentPage - 1) && index<this.tablePage.pageSize * this.tablePage.currentPage) {
                        const element = tempdata[index];
                        this.leftTableData.push(element);
                    }
                    if (index == tempdata.length-1 ) {
                        console.log("到头了");
                    }
                }
                 
                }
                else
                {
                    this.$alter("请添加检验样本库!");
                }
                
            } catch (e) {
                this.$message.warning(e)
            }
        },
        BtnDelete() {
            //删除选中的所有行
            let delSmpID = this.$refs.xTable.getSelectRecords();
            // for (let selectindex = 0; selectindex < delSmpID.length; selectindex++) {
            //     const selectelement = delSmpID[selectindex];
            //    for (let indexDel = 0; indexDel < array.length; indexDel++) {
            //        const elementDel = array[indexDel];
                   
            //    }
            // }
            this.$refs.xTable.remove(delSmpID);
            for (let index = 0; index < delSmpID.length; index++) {
                const delelement = delSmpID[index];
                for (let index = 0; index < this.rowSelect.length; index++) {
                    const element = this.rowSelect[index];
                    if (element['smp_sampleid']==delelement['smp_sampleid']) {
                        this.rowSelect.splice(index,1);
                        index--;
                    }
                }
            }
        },
        BtnDestroy() {
             console.log('开始销毁',new Date());
            let tempSampledata;
            //获取所有销毁数据
            // if (this.allDestroy) 
            //     {
            //     tempSampledata = this.bindLeftTableData;
            //     this.rowSelect = tempSampledata;
            //     }
            // else
            //     tempSampledata = this.rowSelect;


             //需要销毁的样本ID    
            let smpId="";
            var data = this.$refs.xTable.getSelectRecords();
            if(data){
                data.forEach(element => {
                    if(element.smp_status!='50'){
                        smpId+=element.smp_sampleid+",";
                    }  
                });
            }    
           
            
            // for (let index = 0; index < tempSampledata.length; index++) {
            //     const element = tempSampledata[index];
            //     if (element['smp_status']=='50') 
            //     continue;
            //     if (index==tempSampledata.length-1) {
            //         smpId +=element['smp_sampleid']

            //     }
            //     else
            //         smpId +=element['smp_sampleid']+',';
            // }
            if (smpId) {
                this.dialogDestroyVisible =true;
              
                this.$tool.request(
                    {
                        url: "SMP/SMP2/SMP226",
                        method: "post",
                        data: {
                            action: "smp_destory",
                            sampleids:smpId
                        }
                    }
                )
                .then( res=>
                    {
                        this.DestroyData =[];
                        if (res) {
                             console.log('后台返回绑定数据时间',new Date());
                            this.dialogDestroyVisible =false;
                            //rload.close();
                            this.DestroyData = res.smpList;
                            if (res.flag == "1") {
                                this.destroyPager = true;
                                console.log('销毁成功',new Date());
                                this.$message({
                                    message: "销毁成功!",
                                    type: "success",
                                })
                                //销毁行
                                this.leftTableData =this.rowSelect;
                                let xTableNum = this.leftTableData.length;
                                //更新
                                for (let c_index = 0; c_index < this.DestroyData.length; c_index++) {
                                    const ColorElement = this.DestroyData[c_index];
                                    for (let tableIdx = 0; tableIdx < xTableNum; tableIdx++) {
                                        const tabElement = this.leftTableData[tableIdx];
                                        if (tabElement['smp_sampleid']==ColorElement.sampleid) {
                                            //更新样本状态
                                            this.leftTableData[tableIdx]['smp_status'] ='50';
                                            //更新销毁时间
                                            this.leftTableData[tableIdx]['outdate'] =ColorElement.outdate;
                                            //更新销毁人
                                            this.leftTableData[tableIdx]['outuser'] =ColorElement.outuser;
                                            //更新样本架位置说明
                                            this.leftTableData[tableIdx]['shelfposdesc'] =ColorElement.shelfposdesc;
                                        }
                                    }
                                }
                                // this.tablePage.total = this.rowSelect.length;
                                // this.tablePage.currentPage =1;
                                this.rowSmpIDArr = [];
                                this.$refs.xTable.setAllSelection(false);
                                //刷新vxe-table显示
                                // this.$nextTick(()=>{
                                //     let tempdata = this.rowSelect;
                                //     this.leftTableData = [];
                                //     let templeftTableData =[];
                                //     for (let index = 0; index < tempdata.length; index++) {
                                //         if (index>=this.tablePage.pageSize * (this.tablePage.currentPage - 1) && index<this.tablePage.pageSize * this.tablePage.currentPage) {
                                //             const element = tempdata[index];
                                //             templeftTableData.push(element);
                                //         }
                                //     }
                                //     this.leftTableData =templeftTableData;
                                //     console.log('渲染UI结束',new Date());
                                // })
                            }
                            else if (res.flag == "0") 
                                this.$message.error(res.msg);
                            else if (res.flag=='-2') {
                                this.$message.error(res.msg);
                            }
                        }
                    }
                )
                 .catch(e => {
                    this.dialogDestroyVisible =false;
                    this.$message.error(e);
                });
            }
            else
            {
                this.$message.error("请添加销毁数据！");
            }

        },
        BtnClear() {
            //this.BtnQuery()
            this.txtPatNo = "" //病人号
            this.txtPatCardNo = "" //就诊卡号
            this.txtPatName = "" //病人姓名
            this.txtPatAgeStr = "" //年龄
            this.txtShelfType1 = "" //样本架号1*
            this.txtShelfType2 = "" //样本架号2*
            this.txtSendHospCode = "" //送检医院*
            this.txtLendUser = "" //借出人
            this.txtOutUser = "" //销毁人
            this.txtInUser = "" //入库人
            this.txtLendTime = "" //借出次数 默认是0，每次借出后自动加1
            this.txtSmpComments = "" //标本备注
            this.txtSmp_Barcode = "" //条码号
            this.txtPatDiag = "" //临床诊断
            this.LocationCode.locationLeft = "" //冰箱位置1*
            this.LocationCode.locationRight = "" //冰箱位置2*
            this.LocationCode.locationLeftName = ""//冰箱位置名称1*
            this.LocationCode.locationRightName = ""//冰箱位置名称1*
            this.ddlPatSex = "" //性别 1男，2女，3未知
            this.ddlReqDeptNo = "" //申请科室
            this.ddlSmpStatus = "30" //在库状态 打印/在库/借出/销毁
            this.ddlPatTypeCode = "" //病人类型
            this.ddlSmpType = "" //标本类型
            this.ddltxtSmpDate1=  XE.toDateString(new Date(), "yyyy-MM-dd") //留样日期-起始
            this.ddltxtSmpDate2 = "" //留样日期-结束
            this.ddlLendDate1 ="" //借出日期-起始
            this.ddlLendDate2 ="" //借出日期-结束
            this.ddltxtOutDate1 ="" //销毁日期-起始
            this.ddltxtOutDate2 ="" //销毁日期-结束
            this.ddltxtInDate1 ="" //入库日期-起始
            this.ddltxtInDate2 ="" //入库日期-结束
            this.isterm = 'false' //过期标本
            this.$nextTick(() => {
                this.allDestroy = false;    //是否销毁
                this.rowSmpIDArr = [];      //勾选ID数组(销毁行有勾选无ID不勾选)
                this.rowSelect = [];        //勾选行数据(销毁行数据)
                this.$refs.xTable.setAllSelection(false);//勾选UI
                this.leftTableData = [];    //清除table
                this.tablePage.total = 0;   //分页清除
                this.tablePage.currentPage =1;                //分页清除
                this.$refs.rSmp_Barcode.focus()
            })
        },
        BtnPrint() {
            var sql = ""
            sql = btoa(encodeURIComponent(sql))
            jsObj.PrintCustomReport("5002", sql, "lis", "req_master", "") //*
        },
        BtnExport() {
            let options = {
                filename: "SMP310 标本查询-结果信息.csv",
            }
            this.$refs.xTable.exportCsv(options)
        },
        BtnBatchLend() {},
        CurrentChangeEvent({ row, rowIndex }) {
            console.log('我是ROW',row)
            this.tempindex = rowIndex
        },
        CellClassName({ row,rowIndex }) {
            if (this.DestroyData&&this.destroyPager) {
                 return "colgreen";
              
            }
            
        },
         //获取样本库列表
        async ddlSmp_Library() {
            this.$tool
                .request({
                    url: "SMP/SMP1/SMP130",
                    method: "post",
                    data: {
                        action: "q_smp_library",
                        //islibrtype:"1"
                    }
                })
                .then(res => {
                    this.selSmpLibrary_Options = res;
                    if(this.selSmpLibrary_Options.length>0)
                    {
                        this.librid = this.selSmpLibrary_Options[0].librid
                        this.LibridPop = this.librid
                        //this.BtnQuery() //初始化主列表
                    }
                });
        },
        //展开
        BtnOtherShow() {
        this.OtherShow = !this.OtherShow;
            
        },
        //是否启用
         IsChange() {
            this.changeFlag = true;
        },
        //查询冰箱
        ddlLocationCode(){
            if (this.InputCodeArr.filter(item => item.key == this.popdatatype).length == 0) {
            this.$tool
                    .request({
                        url: "ucent/ddl",
                        method: "post",
                        data: {
                            action: 'smp_LocationCode',
                            librid: this.librid,
                        }
                    })
                    .then(res => {
                        if (res) {
                            if (res!='请选择样本库！') {
                                this.InputCodeArr.push({ key: this.popdatatype, list: res });
                            }
                            else  {
                                this.$alter(res);
                            }
                        }
                    })    
            }                          

        },
        //查询DDL
        InputFocus(colcode) {
            this.popdatatype =  colcode;
            this.ddlLocationCode();
            console.log(this.$refs[colcode]);
            if (colcode.toUpperCase().indexOf("_DT") == -1 && colcode.toUpperCase().indexOf("_DATE") == -1 && this.$refs[colcode]['type']!='datetime') {
                this.$refs[colcode].select();
            } else {
                this.$refs[colcode].focus();
            }
        },
        //input输入框双击事件
        inputdblEvent(colcode) {
          this.popdatatype =   colcode;
          this.dialogTableVisible = true;
        },
        //弹出框关闭时自动保存
        popcommonclose() {
            var typecol = (this.popdatatype + "").replace("SMP226_", "");
            if (this.$refs[typecol]) {
                this.LocationCode[typecol] ='';
                this.LocationCode[typecol+'Name'] ='';
                this.$refs[typecol].select();
            }
        },
        //公共组件change事件
        popchange(c, v, row) {
            if (this.popdatatype != "SMP210_report_user" && this.popdatatype != "SMP210_rechk_user") {
                var colcode = this.popdatatype.replace("SMP226_", "");
                this.LocationCode[colcode] = c;
                this.LocationCode[colcode + "Name"] = v;
                this.dialogTableVisible = false;
                this.$refs[colcode].select();
            } else {
                // this.usercode = c;
                // this.username = v;
                // this.userpwd = "";
                // this.dialogLoginVisible = true;
                // this.dialogTableVisible = false;
            }
        }, 
         
        //添加勾选记录
        selectChange({selection,checked,row,rowIndex,$rowIndex,column,columnIndex,$columnIndex,cell},event)
        {
             
            //单选
            if (checked) {
                this.rowSelect.push(row);
            }
            else{
                let tempdata = this.rowSelect;
                for (let index = 0; index < tempdata.length; index++) {
                    const element = tempdata[index];
                    if (element['smp_sampleid']==row['smp_sampleid']) {
                        this.rowSelect.splice(index,1);
                    }
                }
            }
        },
        //选中所有
        selectChangeAll({selection,checked,row,rowIndex,cell},event)
        {
            if (checked) {
                this.allDestroy = true;
                //rowSmpIDArr
                this.rowSmpIDArr = [];
                let tempdata = this.$refs.xTable.getSelectRecords();
                console.log("tempdata",tempdata) 
                for (let index = 0; index < tempdata.length; index++) {
                    const element = tempdata[index];
                    this.rowSmpIDArr.push(element['smp_sampleid']);
                }
            }
            else {
                this.allDestroy = false;
                this.rowSmpIDArr = [];
            }

        },


    },
}
</script>

<style scoped>
.pagetop {
    width: 100%;
    height: 110px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    white-space: nowrap;
    border: 1px solid #ccc;
    position: absolute;
    z-index: 99;
    overflow-x: auto;
    white-space: nowrap;
}

.pagecenter {
    position: absolute;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}

.middle-center {
    position: absolute;
    height: 100%;
    left: 0px;
    right: 405px;
    overflow: auto;
}

.middle-right {
    position: absolute;
    height: 100%;
    width: 400px;
    right: 0px;
}
table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
    width:100%;
}
.pagemain {
    position: absolute;
    height: 100%;
    top: 0px;
    left: 0px;
    right: 0px;
    /* overflow: auto; */
    bottom: 40px;
}
.pagebottom {
    position: absolute;
    height: 45px;
    left: 0px;
    right: 0px;
    overflow: visible;
    bottom: 0px;
    z-index: 999;
}
.table1style tr td {
    padding: 0px 2px 0px 5px;
}

.loading{          
        width: 40px;
        height: 40px;           
        margin: 0 auto;           
        margin-top:0px;    
        position: relative;       
        -webkit-animation: load 3s linear infinite;      
        }      
.loading div{        
        width: 100%;          
        height:100%;         
        position: absolute;       
}     
.loading span{  
    display: inline-block; 
    width: 20px;
    height: 20px;
    border-radius: 50%;         
    background: #99CC66;      
    position: absolute;      
    left: 50%;      
    margin-top: -10px;     
    margin-left: -10px;      
    -webkit-animation: changeBgColor 3s ease infinite;  
}        
@-webkit-keyframes load{           
    0%{                -webkit-transform: rotate(0deg);            }     
    33.3%{                -webkit-transform: rotate(120deg);            }          
    66.6%{                -webkit-transform: rotate(240deg);            }        
    100%{                -webkit-transform: rotate(360deg);            }    
}  
@-webkit-keyframes changeBgColor{
    0%,100%{                background: #99CC66;            }  
    33.3%{                background: #FFFF66;            }      
    66.6%{                background: #FF6666;            }        
}        
.loading div:nth-child(2){
    -webkit-transform: rotate(120deg);        
}        
.loading div:nth-child(3){
     -webkit-transform: rotate(240deg);
}        
.loading div:nth-child(2) span{
    -webkit-animation-delay: 1s;
}        
.loading div:nth-child(3) span{            
    -webkit-animation-delay: 2s;        
}	

::v-deep .vxe-table .vxe-body--column.col-orange {
    background-color: #f8f8f8;
}
::v-deep .el-input--suffix .el-input__inner {
    padding-right: 0px;
}
::v-deep .colgreen {
    background-color: #00ff00 !important;
}
</style>